@extends('admin')
@section('style')
    <style xmlns="http://www.w3.org/1999/html">
        .pagination li {
            width: 27px !important;
            margin: 2px !important;
        }
        #data_list ul li>img{ width: 343px; height: 238px; }
    </style>
@stop
@section('content')
    <div class="h_a">搜索</div>
    <div class="search_type cc mb10">
        <form action="{{url('admin/item')}}" method="get" class="search_form">
            <label for="search_title">查询：</label>
            <select name="add_month">
                @foreach($mouths as $mouth)
                    <option value="{{$mouth->add_month}}">{{$mouth->add_month}}</option>
                @endforeach
            </select>
            <button type="submit" class="btn">提交查询</button>
        </form>
    </div>

    <div class="table_list">
        <div id="data_list" style="clear: both;">
            <ul>
                @foreach($items as $item)
                    <li data-id="{{$item->id}}">
                        <img src="{{asset('/upload/'.$item->dir.'/'.$item->sub_dir.'/'.$item->picName)}}"/>
                        <div style="width: 240px;float: left;height: 8em;">
                            <span>作者：{{$item->author}}</span>
                            <span>上传时间：{{$item->add_month}}</span>
                            </br><label>联系电话：{{$item->mobile}} </label>
                            </br><label>拍摄时间：{{$item->add_time}} </label>
                            </br><label>拍摄地点：{{$item->pic_address}} </label>
                            </br><label> 联系地址：{{$item->authoraddress}}</label>
                        </div>
                        <p class="vote" style="font-size: 24px;padding: 0;text-align: center;color: #f00;">{{$item->vote}}票</p>
                        <div style="float: none;">
                        <input class="checkbox" name="round" type="checkbox" value="1"
                               id="1" {{1 <= $item->round ? 'checked="checked"' : ''}}/>
                        <label for="1">入围</label>
                        @if(1 <= $item->round)
                            <input class="checkbox" name="round" type="checkbox" value="2"
                                   id="2" {{2 == $item->round ? 'checked="checked"' : ''}}/>
                            <label for="1">人气</label>
                        @endif
                            <a href="{{url('admin/item/delete/'.$item->id)}}" class="mr10 J_ajax_del">[删除]</a>
                        </div>
                    </li>
                @endforeach
            </ul>
        </div>

        <div class="summary">
            共有 <span>{{$items->total()}}</span> 条数据
        </div>
        @if ($items->hasPages())
            <div class="pager">
                {!! $items->appends($appends)->render() !!}
            </div>
        @endif
    </div>
@stop

@section('js')
    @parent
    <script>
        $(function () {
            $('.checkbox').on('click', function () {
                __url = '{{url('/admin/item/round')}}' + '/' + $(this).parent().parent().data('id') + '/' + $(this).val();
                $.get(__url, function (data) {
                    if ("" != data.message) {
                        alert(data.message);
                        window.location.href = window.location.href;
                    }
                })
            })
        })
    </script>
@stop